package org.teameleven.quicken.demo;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.teameleven.quicken.accounts.Account;
import org.teameleven.quicken.accounts.Checking;
import org.teameleven.quicken.accounts.Savings;
import org.teameleven.quicken.accounts.Stocks;
import org.teameleven.quicken.factories.AccountFactory;

public class Main {

	public static void main(String[] args) {
		// Get the context file that has the bean definitions...
		ApplicationContext context = 
	             new ClassPathXmlApplicationContext("hwone-context.xml");
		
		// Instantiate the beans to the common factory interface account object...
		AccountFactory<Checking> checkingFactory = (AccountFactory<Checking>) context.getBean("checkingAccount");
		AccountFactory<Savings> savingsFactory = (AccountFactory<Savings>) context.getBean("savingsAccount");
		AccountFactory<Stocks> stocksFactory = (AccountFactory<Stocks>) context.getBean("etradeAccount");
		
		// Use the account objects...
		List<Account> accounts = new ArrayList<Account>();
		accounts.add(checkingFactory.manageNewAccount(new BigDecimal(1000)));
		accounts.add(savingsFactory.manageNewAccount(new BigDecimal(1000)));
		accounts.add(stocksFactory.manageNewAccount(new BigDecimal(1000)));
		

		//see how each collects interest
		for(Account account: accounts){
			account.collectInterest();
			System.out.println(account.getAmount());
		}
		
		
	}

}
